@extends('layouts.app')

@section('title', $topic->title)
@section('description', $topic->excerpt)

@section('content')
    <!-- 广场帖子 -->
    <div class="squarePlate">

        {{--<div class="crumbs">--}}
            {{--<ol class="breadcrumb" style="padding: 8px 0px;margin-bottom: 7px;">--}}
                {{--<li> <span class="glyphicon glyphicon-home " aria-hidden="true"></span>   <a href="javascript:;">首页</a></li>--}}
                {{--<li><a href="#">广场</a></li>--}}
                {{--<li class="active">招聘信息</li>--}}
            {{--</ol>--}}
        {{--</div>--}}
        <br/>

        <div class="container">
            <div class="row">
                <div class="col-md-12  hidden-sm hidden-xs ">
                    <div>
                        @include('layouts._message')
                    </div>

                </div>
                <div class="col-lg-9 col-md-9 hidden-sm hidden-xs author-info ">
                    <div class="plateCont">
                      <div class="plateInfo ">
                            <div class="title">
                                <a href="#" class="tit" title="{{ $topic->title}}">
                                    {{ $topic->title}}</a>
                                <div class="tips">
                                    <p>
                                    <i class="glyphicon glyphicon-folder-open" aria-hidden="true"></i>
                                    <a href="{{ route('categories.show', $topic->forumCategory->id) }}" title="{{ $topic->forumCategory->name }}">
                                        &nbsp;{{ $topic->forumCategory->name }}
                                    </a>
                                    </p>
                                    <p>
                                        <a href="{{ route('users.show', $topic->user->id) }}"> {{$topic->user->name }}</a>
                                        发表于
                                        {{ $topic->created_at->diffForHumans() }}
                                    </p>
                                    {{--<p>最后回复由 <a href="{{ route('users.show', $topic->user->id) }}"> {{$topic->user->name }}</a> 于{{ $topic->updated_at->diffForHumans() }}</p>--}}
                                    <p>{{$topic->view_count }}阅读</p>

                                    <div class="operation">

                                        <a href="#" class="fr" title="收藏">举报</a>
                                        <a href="#" class="fr" title="收藏">收藏</a>
                                        <a href="#reply_box" class="fr"  title="回复">{{$topic->view_count}} 回复</a>

                                    </div>
                                </div>
                            </div>
                            <hr>
                            <div class="modular topic-body ">
                                {!! $topic->body !!}
                            </div>
                            <div class="share">
                                <div class="bdsharebuttonbox fl">
                                    <a href="#" class="bds_more" data-cmd="more"></a>
                                    <a href="#" class="bds_qzone" data-cmd="qzone"></a>
                                    <a href="#" class="bds_tsina" data-cmd="tsina"></a>
                                    <a href="#" class="bds_tqq" data-cmd="tqq"></a>
                                    <a href="#" class="bds_renren" data-cmd="renren"></a>
                                    <a href="#" class="bds_weixin" data-cmd="weixin"></a>
                                </div>
                                <div class="info fl"><p><a href="{{ route('users.show', $topic->user->id) }}"> {{$topic->user->name }}</a> 于 {{ $topic->updated_at->diffForHumans() }} 最后修改</p></div>
                                @can('update', $topic)
                                    <div class="operation">


                                            <a  href="{{ route('topics.edit', $topic->id) }}" class="fr btn btn-default btn-xs" role="button">
                                                <i class="glyphicon glyphicon-edit"></i> 编辑
                                            </a>
                                        <form action="{{ route('topics.destroy', $topic->id) }}" method="post">
                                            {{ csrf_field() }}
                                            {{ method_field('DELETE') }}
                                            <button href="{{ route('topics.destroy', $topic->id) }}" class="fr btn btn-default  btn-xs" role="button">
                                                <i class="glyphicon glyphicon-trash"></i> 删除
                                            </button>
                                        </form>
                                    </div>
                                @endcan
                            </div>


                        </div>
                    </div>
                    <div class="plateReplyCont">
                        {{--回帖列表--}}
                      @include('forum.forum_topics._topics_reply', ['replies' => $topic->replies()->with('user')->paginate(20),'topicCount'=>$topic->view_count])
                        @includeWhen(Auth::check(), 'forum.forum_topics._topics_reply_box',['topic' => $topic])
                    </div>
                </div>

                <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 topic-content">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div class="text-center">
                                作者：{{ $topic->user->name }}
                            </div>
                            <hr>
                            <div class="media">
                                <div align="center">
                                    <a href="{{ route('users.show', $topic->user->id) }}">
                                        <img class="thumbnail img-responsive" src="{{ $topic->user->avatar }}" width="300px" height="300px">
                                    </a>
                                </div>
                            </div>

                            <div class="stats">
                                <a href="{{ route('users.followings', $topic->user->id) }}" style="border-left:0px;">
                                    <strong id="following" class="stat">
                                        {{ count($topic->user->followings) }}
                                    </strong>
                                    关注
                                </a>
                                <a href="{{ route('users.followers', $topic->user->id) }}">
                                    <strong id="followers" class="stat">
                                        {{ count($topic->user->followers) }}
                                    </strong>
                                    粉丝
                                </a>
                                <a href="{{ route('users.show', $topic->user->id) }}">
                                    <strong id="statuses" class="stat">
                                        12
                                    </strong>
                                    动态
                                </a>
                            </div>
                            <div  class="text-center">
                                <hr>
                                普通会员 L5  - 活跃于 1天前

                            </div>
                            <div class="" >
                                <hr>
                                @if (Auth::check())
                                    @include('users._follow_form',['user'=>$topic->user])
                                @else
                                    {{--游客登录--}}
                                    <button type="submit" class="btn  btn-primary btn-block">关注</button>
                                @endif
                            </div>
                            <div style="margin-top: 15px">
                                @if (!Auth::check() || $topic->user->id !== Auth::user()->id)
                                    <button type="submit" class="btn  btn-default btn-block">
                                        <span class="glyphicon glyphicon-envelope" aria-hidden="true"></span> 私信
                                    </button>
                                @else

                                    <button  class="btn  btn-default btn-block" onclick="window.location.href='{{route('users.edit',Auth::user()->id)}}'">
                                        {{--<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>--}}
                                        编辑个人资料
                                    </button>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>

             </div>
        </div>
    </div>

@stop